package com.mohan.system.manage.realm;

import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.JavaUuidSessionIdGenerator;
import org.apache.shiro.session.mgt.eis.SessionIdGenerator;

import java.io.Serializable;

import static com.mohan.calligraphy.constant.RedisConstant.REDIS_PREFIX_LOGIN;

/**
 * @author mohan
 */
public class ShiroSessionIdGenerator implements SessionIdGenerator {
    /**
     * 生成sessionId
     * @param session
     * @return
     */
    @Override
    public Serializable generateId(Session session) {
        Serializable sessionId = new JavaUuidSessionIdGenerator().generateId(session);
        return String.format(REDIS_PREFIX_LOGIN,sessionId);
    }
}
